const Koa = require('koa');
const bodyParser = require('koa-bodyparser');

// const userRouter = require('../router/user.router');
// const authRouter = require('../router/auth.router');
const errorHandler = require('./error-handle');
const useRouter = require('../router');

const app = new Koa();

// 路径 -- 中间件映射


app.use(bodyParser());
// app.use(userRouter.routes());
// app.use(userRouter.allowedMethods()); //判断请求是否存在
// app.use(authRouter.routes());
// app.use(authRouter.allowedMethods()); //判断请求是否存在
useRouter(app);

app.on('error', errorHandler);

module.exports = app;